package com.xuhao.examai.scoring.infrastructure.persistence;

import com.xuhao.examai.scoring.domain.models.ExamRecord;
import com.xuhao.examai.scoring.domain.repositories.ExamRecordRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class ExamRecordRepositoryImpl implements ExamRecordRepository {

	private final ExamRecordJpaRepository examRecordJpaRepository;

	@Override
	public ExamRecord save(ExamRecord examRecord) {
		return examRecordJpaRepository.save(examRecord);
	}

	@Override
	public Optional<ExamRecord> findById(Long id) {
		return examRecordJpaRepository.findById(id);
	}

	@Override
	public List<ExamRecord> findByExamId(Long examId) {
		return examRecordJpaRepository.findByExamId(examId);
	}

	@Override
	public List<ExamRecord> findByStudentId(Long studentId) {
		return examRecordJpaRepository.findByStudentId(studentId);
	}

	@Override
	public List<ExamRecord> findByStatus(String status) {
		return examRecordJpaRepository.findByStatus(status);
	}

	@Override
	public Optional<ExamRecord> findByExamIdAndStudentId(Long examId, Long studentId) {
		return examRecordJpaRepository.findByExamIdAndStudentId(examId, studentId);
	}

	@Override
	public void deleteById(Long id) {
		examRecordJpaRepository.deleteById(id);
	}

	@Override
	public boolean existsById(Long id) {
		return examRecordJpaRepository.existsById(id);
	}
}